package com.example.action;

import com.example.bean.Product;
import com.example.service.ProductService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: AstrosQ
 * @Date: 2024/11/19 15:02
 */
@WebServlet("/productInfo")
public class ProductInfoServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int pid = Integer.parseInt(req.getParameter("pid"));
        ProductService service = new ProductService();
        Product product = service.selectProductInfoById(pid);
        req.setAttribute("product", product);
        req.getRequestDispatcher("product_info.jsp").forward(req, resp);
    }
}